package cn.dglydrpy.study.algorithm.learning.unionfind;

import java.util.ArrayList;
import java.util.List;

public class UnionFindDemo {

    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        for(int i=1;i<=100;i++){
            list.add(i);
        }
        
        UnionFind<Integer> unionFind = new UnionFind<Integer>(list);

        unionFind.union(2,4);
        unionFind.union(4,8);
        unionFind.union(1,3);
        unionFind.union(5,7);

        System.out.println(unionFind.isSameSet(2,8));
        System.out.println(unionFind.sets());
        System.out.println(unionFind.findFather(8).getValue());

        System.out.println("==========");
        unionFind.parents.forEach((k,v) -> System.out.println(k + ":" + v));

        System.out.println("==========");
        unionFind.sizeMap.forEach((k,v) -> System.out.println(k + ":" + v));
        
    }
}
